<?php

$_AUTH = array(
    "TRANSICTION METHOD" => AUTH_USE_COOKIE
);

function auth_set_option($opt_name, $opt_value){
    global $_AUTH;
    
    $_AUTH[$opt_name] = $opt_value;
}

function auth_get_option($opt_name){
    global $_AUTH;
    
    return is_null($_AUTH[$opt_name])
        ? NULL
        : $_AUTH[$opt_name];
}

function auth_clean_expired(){
    global $_CONFIG;
    
    $result = mysql_query("SELECT creation_date FROM ".$_CONFIG['table_sessioni']." WHERE uid='".auth_get_uid()."'");
    if($result){
        $data = mysql_fetch_array($result);
        if($data['creation_date']){
            if($data['creation_date'] + $_CONFIG['expire'] <= time()){
                switch(auth_get_option("TRANSICTION METHOD")){
                    case AUTH_USE_COOKIE:
                        setcookie('uid');
                    break;
                    case AUTH_USE_LINK:
                        global $_GET;
                        $_GET['uid'] = NULL;
                    break;
                }
            }
        }
    }
    
    mysql_query("
    DELETE FROM ".$_CONFIG['table_sessioni']."
    WHERE creation_date + ".$_CONFIG['expire']." <= ".time()
    );
}

function auth_get_uid(){
    
    $uid = NULL;

    switch(auth_get_option("TRANSICTION METHOD")){
        case AUTH_USE_COOKIE:
            global $_COOKIE;
            $uid = $_COOKIE['uidg'];
        break;
        case AUTH_USE_LINK:
            global $_GET;
            $uid = $_GET['uidg'];
        break;
    }

    return $uid ? $uid : NULL;
}

function auth_get_status(){
    global $_CONFIG;

    auth_clean_expired();
    $uid = auth_get_uid();
    if(is_null($uid))
        return array(100, NULL);
    
    $result = mysql_query("SELECT U.username as username
    FROM ".$_CONFIG['table_sessioni']." S,".$_CONFIG['table_utenti']." U
    WHERE S.user_id = U.id and S.uid = '".$uid."'");
    
    if(mysql_num_rows($result) != 1)
        return array(100, NULL);
    else{
        $user_data = mysql_fetch_assoc($result);
        return array(99, array_merge($user_data, array('uid' => $uid)));
    }
}

function auth_login($uname, $passw){
    global $_CONFIG;
	//die("$uname $passw");
    $result = mysql_query("
    SELECT *
    FROM ".$_CONFIG['table_utenti']."
    WHERE username='$uname' and password=MD5('$passw')"
    );
	//die("SELECT * FROM ".$_CONFIG['table_utenti']." WHERE username='$uname' and password=MD5('$passw')");
    if(mysql_num_rows($result) != 1){
        return array(AUTH_INVALID_PARAMS, NULL);
    }else{
        $data = mysql_fetch_array($result);
        return array(AUTH_LOGEDD_IN, $data);
    }
}

function auth_generate_uid(){

    list($usec, $sec) = explode(' ', microtime());
    mt_srand((float) $sec + ((float) $usec * 100000));
    return md5(uniqid(mt_rand(), true));
}

function auth_register_session($udata){
    global $_CONFIG;
    
    $uid = auth_generate_uid();
    
    mysql_query("
    INSERT INTO ".$_CONFIG['table_sessioni']."
    (uid, user_id, creation_date)
    VALUES
    ('".$uid."', '".$udata['id']."', ".time().")
    "
    );
    if(!mysql_insert_id()){
        return array(AUTH_LOGEDD_IN, $uid);
    }else{
        return array(AUTH_FAILED, NULL);
    }
}

function auth_logout(){
    global $_CONFIG;

    $uid = auth_get_uid();
    
    if(is_null($uid)){
        return false;
    }else{
        setcookie('uidg');
        setcookie('id_user');
        mysql_query("
        DELETE FROM ".$_CONFIG['table_sessioni']."
        WHERE uid = '".$uid."'"
        );
        return true;
    }
}

function check_cookie($cookietest) {
         if (empty($_COOKIE)) {
          if ($cookietest=="" || !isset($cookietest)) {
            $message = "test";
            setcookie("test",$message);
            header("Refresh: 0; URL=".$_SERVER["PHP_SELF"]."?cookietest=1");
            exit;
           }
         else
          return false;  }
         else
            /*foreach ($_COOKIE as $key=>$value) {
            echo "nome:".$key." valore:".$value;  }  */
             return true;
}

function login($uname,$passw)  {
    global $_CONFIG;
         list($status, $user) = auth_get_status();
         //echo $uname." ".$passw;
         if($status == AUTH_NOT_LOGGED)  {
          $uname = (trim($uname));
          $passw = (trim($passw));
          if($uname == "" or $passw == "")  {
           $status = AUTH_INVALID_PARAMS;
            }  else {
               list($status, $user) = auth_login($uname, $passw);
               if(!is_null($user)){
                list($status, $uid) = auth_register_session($user);
               }
              }
          }
          switch($status){
            case AUTH_INVALID_PARAMS:
             header("Refresh: 3;URL=index.html");
             echo "<div align=center>Hai inserito dati non corretti ... attendi</div>";
            break;
            case AUTH_LOGEDD_IN:
            case AUTH_LOGGED:
             setcookie('uidg', $uid,time() + $_CONFIG['expire']);
             setcookie('id_user', $user['id'],time() + $_CONFIG['expire']);
             setcookie('lang', 'ita', time()+ $_CONFIG['expire']);
			 header("Location:gestione.php");
             //echo '<div align="center">Login effettuato con successo! ... attendi il reindirizzamento</div>';
            break;
            case AUTH_FAILED:
             header("Refresh: 3;URL=index.html");
             echo '<div align="center">Fallimento durante il tentativo di connessione ... attendi</div>';
            break;
           }
}

function upload_resize_image($image_name,$image_type)   {
  global $path_tmp,$path_tmp_tmb;
//start thumbnailer
      switch($image_type)  {
          case "image/jpeg":
          case "image/pjpeg":
           header('Content-type: image/jpeg');
          break;

          case "image/gif":
           header('Content-type: image/gif');
          break;

          case "image/png":
          case "image/x-png":
           header('Content-type: image/png');
          break;
      }
       $thumb = ImageCreateTrueColor(TMB_W,TMB_H);
      switch($image_type)  {
          case "image/jpeg":
          case "image/pjpeg":
           $source = imagecreatefromjpeg($path_tmp.$image_name);
          break;

          case "image/gif":
           $source = imagecreatefromgif($path_tmp.$image_name);
          break;

          case "image/png":
          case "image/x-png":
           $source = imagecreatefrompng($path_tmp.$image_name);
          break;
      }
       imagecopyresampled($thumb, $source, 0, 0, 0, 0, TMB_W, TMB_H, IMAGE_W, IMAGE_H);
      switch($image_type)  {
          case "image/jpeg":
          case "image/pjpeg":
           imagejpeg($thumb,$path_tmp_tmb."tmb_".$image_name,100);
          break;

          case "image/gif":
           imagegif($thumb,$path_tmp_tmb."tmb_".$image_name,100);
          break;

          case "image/png":
          case "image/x-png":
           imagepng($thumb,$path_tmp_tmb."tmb_".$image_name,100);
          break;
      }
}

function ctrl_imagesize($size)  {
     $max_size = 1024*200;
     if($size <= $max_size)
      return 1;
     else
      return 0;
}

function ctrl_imagetype($type)  {
     if($type == "image/jpg" || $type == "image/gif" || $type == "image/png" || $type == "image/pjpeg" || $type == "image/x-png")
      return 1;
     else
      return 0;
}

function getit($lid) {
    global $db, $id_user;
    $ip = $_SERVER["REMOTE_HOST"];
    if (empty($ip)) {
       $ip = $_SERVER["REMOTE_ADDR"];
    }
        $result1 = $db->sql_query("select * from preorder where pid='$lid' and ip='$ip'");
        $numrows = $db->sql_numrows($result1);
        if($numrows > 0) {
            if($show_products_opt == 0) {
                $db->sql_query("update preorder set quantity=quantity+1 where pid='$lid' and ip='$ip'");
            } else {
                $db->sql_query("insert into preorder values (NULL,'$ip', '$lid', now(), '1')");
            }
        }
    if($numrows == '0') {
        $db->sql_query("INSERT into preorder values (NULL,'$ip', '$lid', now(), '1')");
    }
    $result = $db->sql_query("SELECT cid from products where lid='$lid'");
    list($cid)=$db->sql_fetchrow($result);
    //$db->sql_query("update asershop_products set hits=hits+1 where lid='$lid'");
    Header("Location: modules.php?name=$module_name&s_op=viewproduct&cid=$cid");
}

function getparent($parentid,$title,$class,$idpage=0) {
    global $db;
    $parentid = intval($parentid);
    $newTopic = new topic($parentid);
    $cid = $newTopic->idtopic;
    $ptitle = $newTopic->nome;
    if($idpage!=0)
     $title = "<a class=\"$class\" href=\"webpage.php?idtopic=$cid\">".$title."</a>";
    $pparentid = $newTopic->idfather;
    if ($ptitle != "" && $ptitle != $title && $idpage == 0)
	 $title="<a class=\"$class\" href=\"webpage.php?idtopic=$cid\">".$ptitle."</a> > ";
    if ($pparentid!=0) {
    $title = getparent($pparentid,$title,$class);
    }
    return $title;
}

function getparentProd($parentid,$title,$class,$idpage=0) {
    global $db;
    $parentid = intval($parentid);
    $newService = new service($parentid);
    $cid = $newService->idservizio;
    $ptitle = $newService->nome;
    if($idpage!=0)
     $title = "<a class=\"$class\" href=\"listservices.php?idservizio=$cid\">".$title."</a>";
    $pparentid = $newService->idfather;
    if ($ptitle != "" && $ptitle != $title && $idpage == 0)
	 $title="<a class=\"$class\" href=\"listservices.php?idservizio=$cid\">".$ptitle."</a> > ";
    if ($pparentid!=0) {
    $title = getparent($pparentid,$title,$class);
    }
    return $title;
}

function menu($cid)   {
   global $db, $id_user;
   $cid = intval($cid);
   $res = mysql_query("SELECT cid, nome, parentid from categorie where cid='$cid' AND id_user='$id_user';");
    list ($cid1, $nome1, $parentid) = mysql_fetch_array($res);
   $title = "";
   while ($parentid!=0)  {
    $res1 = mysql_query("SELECT cid, nome, parentid from categorie where cid='$parentid' AND id_user='$id_user';");
    list ($cid, $nome, $parentid) = mysql_fetch_array($res1);
    $title = "<b><a class=plain href=\"prodotti.php?cid=$cid\">$nome</a></b> <b>></b> ".$title;
   }
   if ($title == "")
    $title .= "<b><a class=plain href=\"prodotti.php?cid=$cid\">$nome1</a></b>";
   else
    $title.= "<b><a class=plain href=\"prodotti.php?cid=$cid1\">$nome1</a></b>";
   return $title;
}

function check_exe($file)   {
    if($file['type'] == "application/octet-stream")
     return true;
    else
     return false; 
}

function upload_images($nome,$file,$update=0,$elementOld="")  {
  	global $path_image, $path_image_tmb, $max_size_image;  
      $image_name = $file['name'];
      if (!file_exists("$path_image_tmb".$file['name'])) {
        //die("".THUMB_DIR.$file['name']."");
       if (ctrl_imagesize($file['size'])) {
          include_once 'includes/upload.class.php';
          $up = new FileUpload(TMP_DIR);
          $up->Upload($file);
          include_once 'includes/image.class.php';
          $img = new Image(TMP_DIR . '/' . $up->filename);
          $result = $img->CreateSourceImage();
          if($result){ 
            //salvo l'immagine con dimensioni originali
            $img->SaveProportionateImage(IMAGE_DIR . '/' . $up->filename, IMAGE_QUALITY, '', '');
            //salvo l'immagine con dimensioni fisse 200 X 75
            $img->SaveProportionateImage(THUMB_DIR . '/' . $up->filename, THUMB_QUALITY, THUMB_HEIGHT, THUMB_WIDTH);
            //libero la memoria cancellando l'immagine sorgente
            $img->Free();
			if($update == 1)  {
	            $image_old = $elementOld;
	            @unlink($path_image.$image_old);
	            @unlink($path_image_tmb.$image_old);
            }
          } else  {
          //se il tipo di img non � supportata 
          //o se il file uploadato nn � un immagine 
          $error = "<table width=100%><tr><td class=error align=center><b>$nome non valida.</b><br><a href=\"javascript:history.go(-1);\"><img src=\"imgs/freccia_prec.gif\" alt=\"indietro\" border=0></a></td></tr></table>";
          return $error;
         }
         $up->DeleteFile();
      }  else  {
        $error = "<table width=100%><tr><td class=error align=center><b>$nome troppo pesante.</b><br><a href=\"javascript:history.go(-1);\"><img src=\"imgs/freccia_prec.gif\" alt=\"indietro\" border=0></a></td></tr></table>";
          return $error;
         }
       }  else  {
        $error = "<table width=100%><tr><td class=error align=center><b>Nome dell'$nome gi� presente.</b><br><a href=\"javascript:history.go(-1);\"><img src=\"imgs/freccia_prec.gif\" alt=\"indietro\" border=0></a></td></tr></table>";
          return $error;
     }
     $error = 0;
     return $error;
}

function getProvince($sigla_m="")  {
  $result = mysql_query("SELECT sigla,provincia FROM province ORDER BY provincia ASC;");
  $content = "";
  while(list($sigla,$provincia) = mysql_fetch_row($result))  {
   $content .= "<option value=\"$sigla\"";
   if($sigla_m == $sigla)
    $content .= " selected";
   $content .= ">$provincia</option>\n";   
  }
  return $content; 
}

function getInvestimento($id_m="")  {
  $result = mysql_query("SELECT id,valore FROM investimento ORDER BY id ASC;");
  $content = "";
  while(list($id,$valore) = mysql_fetch_row($result))  {
   $content .= "<option value=\"$id\"";
   if($id_m == $id)
    $content .= " selected";
   $content .= ">$valore &euro;</option>\n";   
  }
  return $content; 
}

function getUbicazione($id_m="")  {
  $result = mysql_query("SELECT id,valore FROM ubicazione ORDER BY id ASC;");
  $content = "";
  while(list($id,$valore) = mysql_fetch_row($result))  {
   $content .= "<option value=\"$id\"";
   if($id_m == $id)
    $content .= " selected";
   $content .= ">$valore</option>\n";   
  }
  return $content; 
}

function getCategorie()  {
  global $id_user;
  $result = mysql_query("SELECT idservizio,nome FROM servizi WHERE id_user='$id_user' ORDER BY nome ASC;");
  $content = "";
  while(list($id,$valore) = mysql_fetch_row($result))  {
   $content .= "<option value=\"$id\"";
   if($id_m == $id)
    $content .= " selected";
   $content .= ">$valore</option>\n";   
  }
  return $content;   
}

function printError($message,$linktoback="")  {
  if($linktoback=="")
    $link = "javascript:history.go(-1);";
  else
    $link = $linktoback;  
  $error = "<table width=100% cellpadding=2><tr><td class=error align=\"center\"><b>$message</b><br><a href=\"$link\">Ritorna</a></td></tr></table>";
  return $error;
}

function printWebError($message,$linktoback="",$back)  {
  if($linktoback=="")
    $link = "javascript:history.go(-1);";
  else
    $link = $linktoback;  
  $error = "<table class=plain width=100% cellpadding=2><tr><td class=error align=\"center\"><b>$message</b><br><a class=plain href=\"$link\">$back</a></td></tr></table>";
  return $error;
}

function ControllaCF($cf)
{
    if( $cf == '' )  return '';
    if( strlen($cf) != 16 )
        return "La lunghezza del codice fiscale non &egrave;"
        ."corretta: il codice fiscale dovrebbe essere lungo "
        ."esattamente 16 caratteri.";
    $cf = strtoupper($cf);
    if( ! ereg("^[A-Z0-9]+$", $cf) ){
        return "Il codice fiscale contiene dei caratteri non validi:"
        ." i soli caratteri validi sono le lettere e le cifre.";
    }
    $s = 0;
    for( $i = 1; $i <= 13; $i += 2 ){
        $c = $cf[$i];
        if( '0' <= $c && $c <= '9' )
            $s += ord($c) - ord('0');
        else
            $s += ord($c) - ord('A');
    }
    for( $i = 0; $i <= 14; $i += 2 ){
        $c = $cf[$i];
        switch( $c ){
        case '0':  $s += 1;  break;
        case '1':  $s += 0;  break;
        case '2':  $s += 5;  break;
        case '3':  $s += 7;  break;
        case '4':  $s += 9;  break;
        case '5':  $s += 13;  break;
        case '6':  $s += 15;  break;
        case '7':  $s += 17;  break;
        case '8':  $s += 19;  break;
        case '9':  $s += 21;  break;
        case 'A':  $s += 1;  break;
        case 'B':  $s += 0;  break;
        case 'C':  $s += 5;  break;
        case 'D':  $s += 7;  break;
        case 'E':  $s += 9;  break;
        case 'F':  $s += 13;  break;
        case 'G':  $s += 15;  break;
        case 'H':  $s += 17;  break;
        case 'I':  $s += 19;  break;
        case 'J':  $s += 21;  break;
        case 'K':  $s += 2;  break;
        case 'L':  $s += 4;  break;
        case 'M':  $s += 18;  break;
        case 'N':  $s += 20;  break;
        case 'O':  $s += 11;  break;
        case 'P':  $s += 3;  break;
        case 'Q':  $s += 6;  break;
        case 'R':  $s += 8;  break;
        case 'S':  $s += 12;  break;
        case 'T':  $s += 14;  break;
        case 'U':  $s += 16;  break;
        case 'V':  $s += 10;  break;
        case 'W':  $s += 22;  break;
        case 'X':  $s += 25;  break;
        case 'Y':  $s += 24;  break;
        case 'Z':  $s += 23;  break;
        }
    }
    if( chr($s%26 + ord('A')) != $cf[15] )
        return "Il codice fiscale non &egrave; corretto:"
        ." il codice di controllo non corrisponde.";
    return 0;
}

   function get_mime_content_type($filename) {
       $idx = strtolower(end( explode( '.', $filename )) );
       $mimet = array(    'ai' =>'application/postscript',
           'pdf' =>'application/pdf',
           'txt' =>'text/plain',
           'doc' =>'application/msword',
           'zip' =>'application/zip'
       );

       if (isset( $mimet[$idx] )) {
           return $mimet[$idx];
       } else {
           return 'application/octet-stream';
       }
   }
   
   function makeFramedx($insert,$lang)  {
        global $bannerProd,$banner_dx1,$banner_dx2,$banner_dx3,$banner_dx4,$cid,$titnovita,$bgcolor,$titcontent,$registrati,$str_tot;
				 $content = '<table width=100% cellpadding=0 cellspacing=0 class=plain align=center>
				  <tr>
				   <td width=510 valign=top id=cnt-dot>
						<table width="100%" height="50" border="0" cellpadding="0" cellspacing="0">
                  
                  <tr>
                    <td align="center" background="../images/'.$titcontent.'">'.News::doSpot().'</td>
                  </tr>                  
                </table>				 
				 '.$insert.'
				 </td>
				 <td width="200" valign="top"><table width="200" border="0" cellpadding="0" cellspacing="0">
                  <tr valign="middle" style="background-image:url(/images/bkgTitCnt_piscine.gif); background-repeat:repeat-x; background-color:#E7E8E8;">
                    <td width="20" align="center" height="55">&nbsp;</td>
                    </tr>
                </table>
                  <table width="200" border="0" cellpadding="0" cellspacing="0">
                  <tr valign="middle">
                    <td width="20" align="center"><img src="../images/spacer.gif" width="20" height="36"></td>
                    <td width="160" valign="top"><table class="plain" width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
						  <td><a href="/ita/webproduct.php?op=viewcart" rel="nofollow"><strong><img src="/images/carrello.png" border="0"></strong></a></td>
						</tr>
						<tr>
						  <td align="center" style="font-size:12px; font-weight:bold">'.$str_tot.'</td>
						</tr>
						<tr>
						  <td>&nbsp;</td>
						</tr>
						<tr>
						  <td valign="middle">'.$registrati.'</td>
						</tr>
						<tr>
						  <td>&nbsp;</td>
						</tr>
                      <tr>
                        <td align="center">&nbsp;</td>
                      </tr>
					</table></td>
                    <td width="20" align="center"><img src="../images/spacer.gif" width="1" height="1"></td>
                  </tr>
                </table>
				<table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td bgcolor="#999999" style=""><img src="../images/spacer.gif" width="200" height="1"></td>
                    </tr>
                  </table>
				  <table width="200" cellpadding="0" cellspacing="0">
				   <tr>
				    <td align="center" valign="middle" width="100%">'.$bannerProd.'</td>
				   </tr>
				  </table>
                  <table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td bgcolor="#999999" style=""><img src="../images/spacer.gif" width="200" height="1"></td>
                    </tr>
                  </table>
				  <table width="200" cellpadding="10" cellspacing="0">
				   <tr>
				    <td align="center" valign="middle" width="100%">
				    	<form action="/ita/webproduct.php" method="POST">
				    		<div class="tit01" style="text-align:center;margin-bottom:10px;">Guida Gratuita!</div>
				    		<div class="tit02" style="text-align:center;margin-bottom:10px;">Scarica Gratuitamente!! </div>
				    		<div class="plain" style="margin-bottom:10px;">Consigli e Segreti per la Manutenzione della tua Piscina</div>
				    		<div class="plain" style="text-align:center;margin-bottom:5px;">Nome:&nbsp;<input type="text" name="nome_manuale" size="20"></div>
				    		<div class="plain" style="text-align:center;">E-mail:&nbsp;<input type="text" name="mail_manuale" size="20"><input type="hidden" name="op" value="get_manuale"></div>
				    		<div style="text-align:center;"><br></br><input type="submit" value="OTTIENI LA GUIDA"></div>
				    	</form>
				    </td>
				   </tr>
				  </table>
                  <table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td bgcolor="#999999" style=""><img src="../images/spacer.gif" width="200" height="1"></td>
                    </tr>
                  </table>
				  <table width="200" cellpadding="0" cellspacing="0">
				   <tr>
				    <td align="center" valign="middle" width="100%">
				    	<object height="200" width="190" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
	                <param value="/banner/banner_giardino_200x200.swf" name="movie">
	                <param value="high" name="quality">
	                <embed height="200" width="200" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" quality="high" src="/banner/banner_giardino_200x200.swf">
	              </object>
				    </td>
				   </tr>
				  </table>
                  <table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td bgcolor="#999999" style=""><img src="../images/spacer.gif" width="200" height="1"></td>
                    </tr>
                  </table>
				  <table width="200" cellpadding="0" cellspacing="0">
				   <tr>
				    <td align="center" valign="middle">'.$banner_dx1.'</td>
				   </tr>
				  </table>
				  <table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td bgcolor="#999999" style=""><img src="../images/spacer.gif" width="200" height="1"></td>
                    </tr>
                  </table>
				  <table width="200" cellpadding="0" cellspacing="0">
				   <tr>
				    <td align="center" valign="middle">'.$banner_dx2.'</td>
				   </tr>
				  </table>
				  <table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td bgcolor="#999999" style=""><img src="../images/spacer.gif" width="200" height="1"></td>
                    </tr>
                  </table>                  
				  <table width="200" cellpadding="0" cellspacing="0">
				   <tr>
				    <td align="center" valign="middle">'.$banner_dx3.'</td>
				   </tr>
				  </table>
				  <table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td bgcolor="#999999" style=""><img src="../images/spacer.gif" width="200" height="1"></td>
                    </tr>
                  </table>
				  <table width="200" cellpadding="0" cellspacing="0">
				   <tr>
				    <td align="center" valign="middle">'.$banner_dx4.'</td>
				   </tr>
				  </table>
				  <table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td bgcolor="#999999" style=""><img src="../images/spacer.gif" width="200" height="1"></td>
                    </tr>
                  </table>
                  <table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td bgcolor="#999999" style=""><img src="../images/spacer.gif" width="200" height="1"></td>
                    </tr>
                  </table></td>
                      </tr>
                    </table>';
			return $content;          
	}
	
	function makeFramedx_eng($insert,$lang)  {
        global $bannerProd,$banner_dx1,$banner_dx2,$banner_dx3,$banner_dx4;
				 $content = '<table width=100% cellpadding=0 cellspacing=0 class=plain align=center>
				  <tr>
				   <td width=510 valign=top id=cnt-dot>
						<table width="100%" height="50" border="0" cellpadding="0" cellspacing="0">
                  
                  <tr>
                    <td align="center" background="../images/bkgTitCnt.gif">'.News::doSpot().'</td>
                  </tr>                  
                </table>				 
				 '.$insert.'
				 </td>
				 <td width="200" valign="top">
				  <table width="200" border="0" cellpadding="0" cellspacing="0">
                   <tr valign="middle">
                    <td width="20" align="center"><span class="tit02"><img src="../images-eng/tit-novita.gif" width="200" height="55"></span></td>
                    </tr>
                  </table>
                  <table width="200" border="0" cellpadding="0" cellspacing="0">
                   <tr valign="middle">
                    <td width="20" align="center"><img src="../images/spacer.gif" width="20" height="36"></td>
                    <td width="160" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">'.articoli::getNovita($lang).'
                      <tr>
                        <td align="center">&nbsp;</td>
                      </tr>
                    </table></td>
                    <td width="20" align="center"><img src="../images/spacer.gif" width="20" height="36"></td>
                  </tr>
                </table>
                  <table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td bgcolor="#999999" style=""><img src="../images/spacer.gif" width="200" height="1"></td>
                    </tr>
                  </table>
				  <table width="200" cellpadding="0" cellspacing="0">
				   <tr>
				    <td align="center" valign="middle" width="100%">'.$bannerProd.'</td>
				   </tr>
				  </table>
				  <table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td bgcolor="#999999" style=""><img src="../images/spacer.gif" width="200" height="1"></td>
                    </tr>
                  </table>
				  <table width="200" cellpadding="0" cellspacing="0">
				   <tr>
				    <td align="center" valign="middle">'.$banner_dx1.'</td>
				   </tr>
				  </table>
				  <table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td bgcolor="#999999" style=""><img src="../images/spacer.gif" width="200" height="1"></td>
                    </tr>
                  </table>
                  <table width="200" cellpadding="0" cellspacing="0">
				   <tr>
				    <td align="center" valign="middle">'.$banner_dx2.'</td>
				   </tr>
				  </table>
				  <table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td bgcolor="#999999" style=""><img src="../images/spacer.gif" width="200" height="1"></td>
                    </tr>
                  </table>                  
				  <table width="200" cellpadding="0" cellspacing="0">
				   <tr>
				    <td align="center" valign="middle">'.$banner_dx3.'</td>
				   </tr>
				  </table>
				  <table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td bgcolor="#999999" style=""><img src="../images/spacer.gif" width="200" height="1"></td>
                    </tr>
                  </table>
				  <table width="200" cellpadding="0" cellspacing="0">
				   <tr>
				    <td align="center" valign="middle">'.$banner_dx4.'</td>
				   </tr>
				  </table>
				  <table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td bgcolor="#999999" style=""><img src="../images/spacer.gif" width="200" height="1"></td>
                    </tr>
                  </table>
<!--<table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td align="center" bgcolor="#F0F0F0"><a href="../eng/webpage.php?idpage=4"><img src="../images/colDx/web_partners-affiliaz.gif" width="200" height="80" border=0></a></td>
                    </tr>
                  </table>-->
                  <table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td bgcolor="#999999" style=""><img src="../images/spacer.gif" width="200" height="1"></td>
                    </tr>
                  </table>
                  <table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td align="center" bgcolor="#F0F0F0"><img src="../images/colDx/ebay.gif" width="200" height="80"></td>
                    </tr>
                  </table>
                  <table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td bgcolor="#999999" style=""><img src="../images/spacer.gif" width="200" height="1"></td>
                    </tr>
                  </table>
                  <table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td bgcolor="#999999" style=""><img src="../images/spacer.gif" width="200" height="1"></td>
                    </tr>
                  </table>
                  <table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td align="center" bgcolor="#F0F0F0"><a href="https://www.paypal.com/it/cgi-bin/webscr?cmd=xpt/cps/general/DiscoverPayPal-outside" target="_blank"><img src="../images/colDx/paypal_verified.gif" alt="PayPal verified" width="200" height="120" border="0"></a></td>
                    </tr>
                  </table>
                  <table width="200" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td bgcolor="#999999" style=""><img src="../images/spacer.gif" width="200" height="1"></td>
                    </tr>
                  </table></td>
                      </tr>
                    </table>';
			return $content;          
	}
	
	function makeTitContent($navbar,$id="")  {
	  global $titcontent;
	  if($titcontent!="")
	    $bkg = $titcontent;
	  else
	    $bkg = "bkgTitCnt.gif";
	  $content = '<table width="100%" height="55" border="0" cellpadding="0" cellspacing="0">
                  
                  <tr valign="middle">
                    <td valign="bottom" background="../images/'.$bkg.'"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="20"><img src="../images/spacer.gif" width="20" height="20"></td>
                        <td width="670" class="navbar">'.makeNavbar($navbar).'</td>
                        <td width="20"><img src="../images/spacer.gif" width="20" height="20"></td>
                      </tr>
                      <tr>
                        <td><img src="../images/spacer.gif" width="20" height="20"></td>
                        <td class="navbar">&nbsp;</td>
                        <td><img src="../images/spacer.gif" width="20" height="20"></td>
                      </tr>
                    </table></td>
                  </tr>
                  
                </table>';
	  return $content;
	}
	
	function makeNavbar($navbar)  {
	  $content = "<table width=100% class=navbar cellpadding=0 cellspacing=0 border=0>
	  	<tr>
	  	  <td><b>&nbsp;&nbsp;$navbar</b></td>
	  	</tr>
	  				</table>";
	  return $content;
	}
?>